# coding=utf-8

#import os
import logging as log


class GtpChar:
    GTP_CHAR_TYPE_DICT = {
        'NORMAL' : 0,
        'SLASH' : 1,
        'END' : 2,
        'ILLEGAL' : 3
    }
    
    GTP_CHAR_TYPE_TABLE = [0 for x in range(1<<8)]

    def __init__(self):
        self.GTP_CHAR_TYPE_TABLE[ord('\\')] = self.GTP_CHAR_TYPE_DICT['SLASH']
        self.GTP_CHAR_TYPE_TABLE[ord(',')] = self.GTP_CHAR_TYPE_DICT['END']
        self.GTP_CHAR_TYPE_TABLE[ord(']')] = self.GTP_CHAR_TYPE_DICT['END']
        self.GTP_CHAR_TYPE_TABLE[ord('}')] = self.GTP_CHAR_TYPE_DICT['END']
        self.GTP_CHAR_TYPE_TABLE[ord('=')] = self.GTP_CHAR_TYPE_DICT['ILLEGAL']
        self.GTP_CHAR_TYPE_TABLE[ord('[')] = self.GTP_CHAR_TYPE_DICT['ILLEGAL']
        self.GTP_CHAR_TYPE_TABLE[ord('{')] = self.GTP_CHAR_TYPE_DICT['ILLEGAL']

    def get_char_type(self, char):
        return self.GTP_CHAR_TYPE_TABLE[char]

    def is_slash_char(self, char):
        return self.get_char_type(char) == self.GTP_CHAR_TYPE_DICT['SLASH']
         
    def is_string_end_char(self, char):
        return self.get_char_type(char) == self.GTP_CHAR_TYPE_DICT['END']

    def is_string_illegal_char(self, char):
        return self.get_char_type(char) == self.GTP_CHAR_TYPE_DICT['ILLEGAL']

    def is_escape_char(self, char):
        return self.get_char_type(char) != self.GTP_CHAR_TYPE_DICT['NORMAL']

    def is_not_escape_char(self, char):
        return self.get_char_type(char) == self.GTP_CHAR_TYPE_DICT['NORMAL']


if  __name__ == '__main__':
    gtp_char  = GtpChar()

    #print('1 : ',gtp_char.is_slash('\\'))
    #print('2-1 : ',gtp_char.is_string_end(']'))
    #print('2-2 : ',gtp_char.is_string_end('{'))

    print('3-1 : ',gtp_char.is_string_illegal_char(']'))
    print('3-2 : ',gtp_char.is_string_illegal_char('{'))
    print('4 : ',gtp_char.is_escape_char(','))
    print('5 : ',gtp_char.is_not_escape_char(','))


